#import BlackBoard.Activity;
import random;
import BlackBoard.InputSim;
import stgm;
from subprocess import call;

bReadXML = True;
sXmlFile = "./BlackBoard/XmlActs/ActsHmmTest.xml";
nSeed = 3;
inputSim = BlackBoard.InputSim(stgm, nSeed, nTimes=3, bReadXML=bReadXML, sXmlFile=sXmlFile);
#inputSim.printTransitionM();
#inputSim.printPriors();
#inputSim.printStateSpace();
#print "";
#actT0 = [["Approach"], ["*", "P2"]];
#actT1 = [["Approach"], ["P3", "P2"]];
#print inputSim.getIndex(actT0, actT1);
#print inputSim.getIndexPrior(actT1);

inputSim.makeXmlActivities("./BlackBoard/XmlActs/test.xml");
# inputSim.makeXmlActivities("./BlackBoard/XmlActs/ActsHmmAll.xml");


# # blackB = BlackBoard.BlackBoard(inputSim);
# # blackB.addXmlActs_ToBB("./BlackBoard/XmlActs/ActsHmmTest_Small.xml");
# # #blackB.addXmlActs_ToBB("./BlackBoard/XmlActs/ActsHmmTest1.xml");
# # #blackB.addXmlActs_ToBB("./BlackBoard/XmlActs/ActsHmmTest2.xml");
# # #if bReadXML==False: inputSim.printActivities();
# # #blackB.graph.setup();
# # #aActSeq1 = ["300.15", "50.35", "50.60", "300.85", "300.100"];
# # #aActSeq2 = ["300.15", "300.35", "300.60", "300.85", "300.100"];
# # #aActSeq3 = ["300.15", "300.35", "800.60", "800.85", "300.100"];
# # #aActSeq4 = ["300.15", "50.35", "800.60", "300.85", "300.100"];
# # #aActSeqs = [aActSeq1, aActSeq2, aActSeq3, aActSeq4];
# # #print blackB.getProbSeq(aActSeq1);
# # #print blackB.getMaxProbSeq(aActSeqs);
# # #print "\nRemoving Nodes:";
# # #blackB.removeAct("300");
# # #blackB.removeAct("300");
# # #print blackB.getMaxStProb("60");
# # #print blackB.getMaxProbSeq();
# # blackB.getHmms();
# # 
# # aNodes = [];
# # i = 0;
# # print "";
# # for sK in inputSim.aActs_Time:
# #     for j in range(len(inputSim.aActs_Time[sK])):
# #         aNodes.append(inputSim.aActs_Time[sK][j].rootAct);
# #     print i+1, "Priors:", blackB.graph.priorprob(aNodes);
# #     print i+1, "Posts:", blackB.graph.postprob(aNodes);
# #     i += 1;
# #     aNodes = [];
# # 
# # blackB.graph.write2dot(fname='./BlackBoard/DynBB-graph.dot');
# # call(['dot', '-Tpdf', './BlackBoard/DynBB-graph.dot', '-o', './BlackBoard/DynBB-graph.pdf']);
# # call(['evince', './BlackBoard/DynBB-graph.pdf']);
